import api from './index'

// 创建订单
export const createOrder = (orderData) => {
  return api.post('order', orderData)
}

// 创建VIP订单
export const createVipOrder = (orderData) => {
  return api.post('order/vip', orderData)
}

// 创建积分订单
export const createPointsOrder = (orderData) => {
  return api.post('order/points', orderData)
}

// 获取订单详情
export const getOrderDetail = (id) => {
  return api.get(`order/detail/${id}`)
}

// 获取订单列表（按状态）
export const getOrdersByStatus = (status, start = 0, count = 10) => {
  return api.get(`order/by/status/${status}`, {
    params: { start, count }
  })
}

// 获取待付款订单数量
export const getUnpaidCount = () => {
  return api.get('order/unpaid/count')
}

// 获取已付款订单数量
export const getPaidCount = () => {
  return api.get('order/paid/count')
}

// 获取已发货订单数量
export const getDeliveredCount = () => {
  return api.get('order/delivered/count')
}

// 获取已取消订单列表
export const getCanceledOrders = (start = 0, count = 10) => {
  return api.get('order/canceled', {
    params: { start, count }
  })
}

// 获取待付款订单
export const getUnpaidOrders = (start = 0, count = 10) => {
  return api.get('order/status/unpaid', {
    params: { start, count }
  })
} 

// 获取我买到的订单列表
export const getMyPurchases = () => {
  return api.get('order/my-purchases')
}

// 获取我买到的订单详情
export const getMyPurchaseDetail = (orderId) => {
  return api.get(`order/my-purchases/${orderId}`)
}

// 确认收货
export const confirmReceiveOrder = (orderId) => {
  return api.post(`order/${orderId}/confirm-receive`)
} 